<html>
<head>
    <meta charset="utf-8">
</head>
<body>
<script type="text/javascript">

    function cancel() {
        window.location.href = "./nameSearch.php";
    }


</script>
<?php
$name = $_POST ['CName'];
$config = parse_ini_file("config/db_config.ini");
$server = $config["server"];
$username = $config["username"];
$password = $config["password"];
$database = $config["database"];
$link = mysqli_connect($server, $username, $password, $database);

$sql = "SELECT * FROM typhoon_name WHERE name_Chinese like '%" . $name . "%'";
echo $sql, '\n';
$result1 = mysqli_query($link, $sql);
$namerow = mysqli_fetch_row($result1);
$flag = 0;
echo '<table border="1" cellspacing="0px" cellpadding="2px" align="center">';
echo '<tr><td>★★★★★★★★★★★★★★★★★★★★★★★<br/></td></tr>';
echo '<tr><td><h1>☆☆>>台风名称匹配结果<br /></h1></tr></td>';
echo '<tr><td>★★★★★★★★★★★★★★★★★★★★★★★<br/></td></tr>';

while ($namerow != null) {
    $flag++;
    $sql = "SELECT * FROM typhoon_total WHERE name like '" . $namerow [1] . "'";
    echo $sql;
    $result = mysqli_query($link, $sql);
    $row = mysqli_fetch_row($result);


    while ($row != null) {

        echo '<tr><td><h1>&nbsp;&nbsp;&nbsp;>>序号 : ' . floor($row [0] / 10000) . "年第" . sprintf("%03d", ($row [0] % 10000)) . "号气旋" . '</h1></tr></td>';
        echo '<tr><td><h1>&nbsp;&nbsp;&nbsp;>>名称 : ' . $namerow [2] . '</h1></tr></td>';
        echo "<tr><td><h1>&nbsp;&nbsp;&nbsp;>>展示 :<a href = \"show.php?num=" . $row [0] . "&count=" . $row [4] . "&table=typhoon_detail\"target=\"_top\">" . "点击此处进入展示页面" . "</a></h1></tr></td>";
        echo '<tr><td>★★★★★★★★★★★★★★★★★★★★★★★<br/></tr></td>';

        $row = mysqli_fetch_row($result);
    }


    $namerow = mysqli_fetch_row($result1);
}


if ($flag == 0) {

    echo '<tr><td><h1>☆☆>>没有查询到相应台风请核实<br /></h1></tr></td>';
    echo '<tr><td>★★★★★★★★★★★★★★★★★★★★★★★<br/></td></tr></table>';
} else {
    echo '</table>';
}


?>

<br>
<br>
<br>
<br>
<br>
<br>
<div align="center">
    <img src="./back.png" width="470" height="250" onclick="cancel();"
         align="middle">
</div>

</body>
</html>
